package com.ysx.comment.controller;


import com.ysx.comment.dto.CommentRelyDto;
import com.ysx.comment.dto.CommentReplyLikeDto;
import com.ysx.comment.dto.CommentReplySaveDto;
import com.ysx.comment.pojo.ApCommentReply;
import com.ysx.comment.service.ApCommentReplyService;
import com.ysx.comment.vo.CommentReplyVo;
import com.ysx.common.pojo.Result;
import com.ysx.core.controller.AbstractCoreController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
* <p>
* APP评论回复信息表 控制器</p>
* @author ljh
* @since 2021-10-08
*/
@Api(value="APP评论回复信息表",tags = "ApCommentReplyController")
@RestController
@RequestMapping("/apCommentReply")
public class ApCommentReplyController extends AbstractCoreController<ApCommentReply> {

    private ApCommentReplyService apCommentReplyService;

    //注入
    @Autowired
    public ApCommentReplyController(ApCommentReplyService apCommentReplyService) {
        super(apCommentReplyService);
        this.apCommentReplyService=apCommentReplyService;
    }

    //点赞回复
    @PostMapping("/replyLike")
    public Result replyLike(@RequestBody CommentReplyLikeDto commentReplyLikeDto) throws Exception{
        apCommentReplyService.replyLike(commentReplyLikeDto);
        return Result.ok();
    }


    //发表回复
    @PostMapping("/saveReply")
    public Result saveReply(@RequestBody CommentReplySaveDto commentReplySaveDto) throws Exception{
        apCommentReplyService.saveReply(commentReplySaveDto);
        return Result.ok();
    }

    //获取回复列表
    @PostMapping("/loadPage")
    public Result<List<CommentReplyVo>> loadPage(@RequestBody CommentRelyDto commentRelyDto){
        List<CommentReplyVo> commentReplyVoList = apCommentReplyService.loadPage(commentRelyDto);
        return Result.ok(commentReplyVoList);
    }


}

